package top.maof.book.model;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;
import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@TableName("contents")
public class Contents implements Comparable<Contents>, Serializable {
    @TableId(type = IdType.AUTO)
    private Integer id;

    private String url;// http://www.ymxwx.com/book/110/110066/index.html

    private Integer bookId;//斗破苍穹

    private Integer webId;// 衍墨轩

    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date updateDate;

    private String content;//  内容


    @TableField(fill = FieldFill.INSERT)
    private Long insertTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Long updateTime;

    @Override
    public int compareTo(Contents o) {
        if (o.getWebId().intValue() == webId.intValue()) {
            return 0;
        }
        return o.getWebId() > webId ? -1 : 1;
    }


    @Override
    public boolean equals(Object obj) {
        Contents o = (Contents) obj;
        return o.getBookId() == bookId && o.getWebId() == webId;
    }
}
